package com.service.business.rabbitmq.listener;


import com.service.business.member.service.MemberAwardService;
import com.service.business.pay.dto.PayOrder;
import com.service.business.rabbitmq.binding.GiftOrderSink;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
//@EnableBinding(GiftOrderSink.class)
public class GiftOrderReceiverListener {

    @Autowired
    private MemberAwardService memberAwardService;

//    @StreamListener(target = GiftOrderSink.IN_PAY_GIFT_ORDER)
    public void processPayGiftOrder(PayOrder payOrder) throws Exception {
        log.info("receive order:{}", payOrder);
        try {
            memberAwardService.dealMemberPayGiftBagOrder(payOrder);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

}
